import unittest
from time import sleep
from selenium import webdriver

class Baidu(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.base_url = "htps://www.baidu.com"

    def test_search_key_selenium(self):
        self.driver.get(self.base_url)
        self.driver.find_element_by_id("kw").send_keys("selenium")
        self.driver.find_element_by_id("su").click()
        sleep(5)
        title = self.driver.title
        self.assertEqual(title,"selenium_百度搜索")

    def test_search_key_unittest(self):
        self.driver.get(self.base_url)
        self.driver.find_element_by_id("kw").send_keys("unittest")
        self.driver.find_element_by_id("su").click()
        sleep(5)
        title = self.driver.title
        self.assertEqual(title, "unittest_百度搜索")

    def tearDown(self):
        self.driver.quit()

if __name__  == "__main__":
    unittest.main()
